package com.dayou.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.dayou.bean.SysMenu;
import com.dayou.service.ISysMenuService;
import com.dayou.common.core.controller.BaseController;
import com.dayou.common.core.page.TableDataInfo;
import com.dayou.common.core.domain.AjaxResult;
import com.dayou.common.utils.poi.ExcelUtil;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 达幽系统集成框架 - 菜单 信息操作处理
 * 
 * @author dayou
 * @date 2020-04-24
 */
@RestController
@RequestMapping("/sysMenu")
public class SysMenuController extends BaseController
{
	@Autowired
	private ISysMenuService sysMenuService;
												
        /**
         * 查询所有未删除达幽系统集成框架 - 菜单列表
         */
        @PostMapping("/list")
        @ResponseBody
        public TableDataInfo list(SysMenu sysMenu)
        {
			sysMenu.setIsDeleted(0);
            startPage();
            List<SysMenu> list = sysMenuService.selectSysMenuList(sysMenu);
            return getDataTable(list);
        }

        /**
         * 查询所有已删除达幽系统集成框架 - 菜单列表
         */
        @PostMapping("/listDeleted")
        @ResponseBody
        public TableDataInfo listDeleted(SysMenu sysMenu)
        {
			sysMenu.setIsDeleted(1);
            startPage();
            List<SysMenu> list = sysMenuService.selectSysMenuList(sysMenu);
            return getDataTable(list);
        }

        /**
         * 伪删除达幽系统集成框架 - 菜单
         */
        @PostMapping("/fakeDelete")
        @ResponseBody
        public int fakeDelete(String ids)
        {
            return sysMenuService.fakeDeleteSysMenuByIds(ids);
        }

        /**
         * 恢复达幽系统集成框架 - 菜单
         */
        @PostMapping("/resume")
        @ResponseBody
        public int resume(String ids)
        {
            return sysMenuService.resumeSysMenuByIds(ids);
        }
			
    /**
	 * 查询所有达幽系统集成框架 - 菜单列表
	 */
	@PostMapping("/listAll")
	@ResponseBody
	public TableDataInfo listAll(SysMenu sysMenu)
	{
		startPage();
        List<SysMenu> list = sysMenuService.selectSysMenuList(sysMenu);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出达幽系统集成框架 - 菜单列表
	 */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysMenu sysMenu)
    {
    	List<SysMenu> list = sysMenuService.selectSysMenuList(sysMenu);
        ExcelUtil<SysMenu> util = new ExcelUtil<SysMenu>(SysMenu.class);
        return util.exportExcel(list, "sysMenu");
    }
	
	/**
	 * 新增保存达幽系统集成框架 - 菜单
	 */
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(SysMenu sysMenu)
	{		
		return toAjax(sysMenuService.insertSysMenu(sysMenu));
	}

	/**
	 * 修改保存达幽系统集成框架 - 菜单
	 */
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(SysMenu sysMenu)
	{		
		return toAjax(sysMenuService.updateSysMenu(sysMenu));
	}
	
	/**
	 * 删除达幽系统集成框架 - 菜单
	 */
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(sysMenuService.deleteSysMenuByIds(ids));
	}
	
}
